/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package transformer;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author Rishav
 */
public class DateConv implements Transformer{
    private String data;

    @Override
    public void setData(String data) {
        this.data=data;
    }

    @Override
    public String evaluate(String... args) {
        if (args.length != 2) {
            return "Number of Arguments are not correct";
        } else {
            DateFormat fromdf = new SimpleDateFormat(args[0]);
            DateFormat todf = new SimpleDateFormat(args[1]);
            try {
                return todf.format(fromdf.parse(data));
            } catch (ParseException ex) {
                Logger.getLogger(DateConv.class.getName()).log(Level.SEVERE, null, ex);
                return "Format of date is not matched";                
            }
        }
    }
    
}
